package com.acargil.sudoku.view.listeners;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import com.acargil.sudoku.view.ISudokuView;

public     /**
 * Draw an inner highlighting rectangle inside a cell. 
 * */
class SelectionListener implements MouseListener {

    private ISudokuView view;
    private static MouseListener instance = null;
    
    protected SelectionListener(ISudokuView view) {
        this.view = view;
    }

    public void mouseClicked(MouseEvent e) { }

    public void mousePressed(MouseEvent e) {
    	if (MouseEvent.BUTTON1 == e.getButton()) {
    		view.setSelectionCoordinates(e.getX(), e.getY());
    	}
    }

    public void mouseReleased(MouseEvent e) { }

    public void mouseEntered(MouseEvent e) { }

    public void mouseExited(MouseEvent e) { }

	public static MouseListener getInstance(ISudokuView view) {
		if (instance == null) {
			instance = new SelectionListener(view);
		}
		
		return instance;
	}
}